home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
ca29_3.zip
/
HOST.SRC
< prev
next >
Wrap
Text File
|
1992-07-03
|
18KB
|
689 lines
; trace on ; Debugging
;
; ----- COM-AND Scripted host mode ----------------------------------
;
; Goals:
; o Must autodetect caller's baud rate
; o Must work correctly for modems reporting true CD and otherwise.
; o Must log all activity
;
; Functions:
; o Passworded log-on
; o DIR of current directory
; o CHDIR command
; o UP and DOWNLOADS
; o Graphical path display (using P/D TREED program)
; o Passworded DOS access (dangerous!)
; o Passworded drop-to-DOS using a doorway function
;
; Commenced: 10/29/87 R.McG
; Updated: 2/--/89 R.McG
; 10/--/89 R.McG ZMODEM added
; Ver 1.1: 11/--/90 R.McG HOSETUP added
; 6/--/91 R.McG DROPDOS added
; --------------------------------------------------------------
; Data for this script are established through the HOSETUP script.
; The drop-to-DOS requires a doorway function (such as DOORWAY,
; by Marshsall Dudley), and the script HOSTART. The only other
; file requisite to this HOST script is the TREED p/d utility.
; --------------------------------------------------------------
;
; Initialize
;
LEGEND "Scripted HOST mode (1.1). Press ESC to exit."
;
; Set default values (in case HOSTDAT does not exist)
;
S20 = "_PARM"(11:14)*","*"_PARM"(0:3) ; Port(4),speed(4)
S21 = "ATE0Q0V1X1S0=2 S7=30 S9=10^M" ; Standard MINIT for HOST
S22 = "****" ; Set default logon password
S23 = "xxxx" ; Set default DOS password
S24 = "" ; Drop to DOS command
;
; Initialize COM related values (This is done here to allow HOSTDAT
; ... edits to override these settings)
;
SET PARITY NONE ; fixed no parity
SET DATA 8 ; fixed 8 data bits
SET STOP 1 ; fixed 1 stop bit
SET MASK ON ; accept 7 or 8 bits
SET CR_IN CR_LF ; Display received c/rs as a cr/lf
SET ASCII UP_LF LF ; Send LFs
SET SOFTFLOW ON ; Allow XON/XOFF
;
; Replace above values from HOSTDAT, if that script exists
;
IF ISSC "HOSTDAT" FCALL "HOSTDAT"
;
; Initialize variables that must be constant
;
S0 = S22 ; Set to our subdirectory
S3 = S23 ; Set subdir for files
SUBDIR S29 ; Read current subdir
DLDIR S28 ; Read current download subdir
;
; Set initial values that do not change port setting
;
LOG MARK ON ; Timestamp logging
CLOG "* Host script loaded"
ON ESCAPE GOSUB End ; Exit routine
SET INAFTER OFF ; Turn off init after hangup
SET ALARM OFF ; Turn off alarm
SET ATIME 1 ; Set alarm time to 1 second
;
; If this is a restart, pickup at the main prompt
;
SET PORT S20(0:3) ; Starting port
IF FCALLED and ISFILE "HOSTTEMP.BAT"
SET RECHO ON ; Restart - need to reenable
LOG OPEN "HOSTLOG" ; .. reenable
CLOG "* Return from drop-to-DOS"
GOTO Main_Prompt
ENDIF
;
; Initialize values that change port setting, and start a new call
;
SET BAUD S20(5:8) ; Starting speed
TRANSMIT "_MESCAPE" ; Initialize modem (modem escape)
GOTO Restart ; Branch around subroutines
;
; -----------------------------------------------------------------------
; Subroutine: End of HOST
; -----------------------------------------------------------------------
;
End:
HANGUP ; Hangup the phone
CLOG "* HOST script terminated" ; Log completion
SET DLDIR S28 ; Reset dldir
CHDIR S29 ; Reset to default directory
RESET ; Reset default values
CLEAR ; Clear screen
MESS "HOST terminated... type Alt-X to exit COM-AND^M^J^M^J"
TRAN "_MINIT" ; Initialize modem from defaults
DELETE "\HOSTTEMP.TXT" ; Cleanup
EXIT ; Exit
;
; Subroutine: Read from the caller into S9
; .. This handles 'disconnect' and timeouts.
;
Read_Comm:
RGET S9 80 180 ; wait for a connection
IF NOT CONNECTED ; If modem reports CD dropped
GOTO Disconnect ; Goto disconnect
ENDIF
IF NOT SUCCESS ; If timeout on the RGET
GOTO Timeout ; .. issue message and disconnect
ENDIF
FIND S9 "NO CARRIER" ; Test for message from modem
IF FOUND ; If modem didn't report 'CD' true
GOTO Disconnect ; Goto disconnect
ENDIF
SET FLAG(0) OFF ; Report to caller
RETURN ; Return with text in S9
;
; Timeout on the call
;
Timeout:
TRAN "^M^J... autodisconnect due to timeout"
MESSAGE "^M^J... autodisconnect due to timeout"
GOTO RComm_Exit ; Exit cycle in the usual manner
;
; Disconnect was reported.
;
Disconnect:
MESSAGE "^M^JCaller disconnected"
;
; Read_Comm error exit
;
RComm_Exit:
SET FLAG(0) ON ; Report to caller
RETURN ; Return to the caller
;
; Usages:
; S0 -> main password
; S1 -> ID
; S2 -> Default drive/subdir
; S3 -> DOS password
; S8 -> File name buffer
; S9 -> General read buffer
;
; Begin the sequence...
;
Restart:
CHDIR S29 ; Reset to default drive
SET RECHO OFF ; Turn off echo for us
SET RDISP OFF ; Disable display of rcvd chars
CLEAR ; Clear screen
LOCATE 0,0 ; Set to home
;
; Go into auto answer (echo off, answer on 3rd)
; Also: Return result codes, word form, with CONNECT 1200
;
;
HANGUP ; HANGUP and leave modem in cmd mode
MESSAGE "^M^JWaiting...!"
PAUSE 3 ; Wait 3 secs
SET BAUD S20(5:8) ; Starting speed
TRANSMIT S21 ; Transmit modem initialization
;
; Wait for a connect
;
WAIT_IT_OUT:
RGET S9 80 180
IF NOT SUCCESS
GOTO Wait_IT_Out
ENDIF
FIND S9 "NO CARRIER"
IF FOUND
GOTO Restart
ENDIF
FIND S9 "CONNECT"
IF NOT FOUND
GOTO WAIT_IT_OUT
ENDIF
;
; Connection established: Adjust our linespeed if need be
;
GOSUB AutoBaud ; Change rate according to CONNECT MSG
;
; Issue a greeting
;
PAUSE 2 ; Let the modem settle
RFLUSH ; Clear junk
TRAN "^M^JThe Flying Scotsman greets you!!^M^J"
SET RECHO ON ; Turn on echo (back to caller)
SET RDISP ON ; Turn on display of rcvd chars
LOG OPEN "HOSTLOG"
;
; Request an ID
;
ID_Query:
MESS "^M^JID prompt: " ; Local console indicator
TRANSMIT "^M^JEnter your ID: "
GOSUB Read_Comm ; Read into S9
IF FLAG(0) ; If first flag rtns set
GOTO Exit ; .. disconnect and start over
ENDIF ; ..
SWITCH S9
CASE "_NULL" ; Test for nothing entered
TRAN "You must be someone^M^J"
GOTO Exit ; Don't let noone in
ENDCASE ; End of ridicule
ENDSWITCH ; End of ID test
CLOG "* Host mode logon by "*S9
;
; Request a password
;
TRANSMIT "^M^JEnter your password: "
LOG SUSPEND
SET RECHO OFF ; Turn of echo of received text
SET RDISPLAY OFF ; Turn off echo to console too
GOSUB Read_Comm ; Read into S9
IF FLAG(0) ; If first flag rtns set
GOTO Exit ; .. disconnect and start over
ENDIF ; ..
LOG RESUME ; Restore logging
SET RECHO ON ; Restore echo
SET RDISPLAY ON ; Turn on echo to console again
;
; Test for the main password
;
SWITCH S9
CASE S0 ; Test for match with S0
TRANSMIT "^M^J" ; OK - good password
ENDCASE ; End match with S0
DEFAULT ; Not one of the above
TRANSMIT "Sorry , but you're not authorized."
GOTO Exit ; And disconnect
ENDCASE ; End of DEFAULT
ENDSWITCH
;
; Now - do something
;
Main_Prompt:
MESS "^M^JMain prompt: "; Local console indicator
TRAN "^M^JC)hdir F)ilelist, P)athlist, U)pload, D)ownload, or E)xit: "
GOSUB Read_Comm ; Read into S9
IF FLAG(0) ; If first flag rtns set
GOTO EXIT ; .. disconnect and start over
ENDIF ; ..
SWITCH S9 ; Test the entry
CASE "C"
GOTO CHDIR
ENDCASE
CASE "D"
GOTO DOWNLOAD
ENDCASE
CASE "E"
TRAN "Ok... bye^M^J"
GOTO EXIT
ENDCASE
CASE "F"
GOTO FILELIST
ENDCASE
CASE "P"
GOTO PATHLIST
ENDCASE
CASE "U"
GOTO UPLOAD
ENDCASE
CASE "X"
GOTO DOS
ENDCASE
CASE "Y"
GOTO DROPDOS
ENDCASE
CASE "OFF"
TRAN "Ok... bye^M^J"
GOTO EXIT
ENDCASE
;
; Default case for typists
;
DEFAULT
FIND S9 "CHDIR" ; Try for larger
IF FOUND ; If entry contained "CHDIR"
GOTO CHDIR
ENDIF